package cloud.lysky.java.on.design_pattern.factory;

/**
 * @author luoly
 * @describe
 * @date 2022-08-20 13:35
 **/
//工厂模式  --产品工厂
public class ProductFactory {
    public static Product createProduct(String name){
        switch (name){
            case "loan": return new Loan(name);
            case "stock": return new Stock(name);
            case "bond":return new Bond(name);
            default:throw new RuntimeException("No such product" + name);
        }
    }
}